package com.xujl.utilslibrary.system;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.support.annotation.ArrayRes;
import android.support.annotation.ColorRes;
import android.support.annotation.DimenRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;

/**
 * Created by xujl on 2017/11/6.
 */

public class ResUtil {

    public static Resources getResources () {
        return DelegateApplication.getContext().getResources();
    }

    public static float getDimension (@DimenRes int id) {
        return getResources().getDimension(id);
    }

    public static int getColor (@ColorRes int resId) {
        return ContextCompat.getColor(DelegateApplication.getContext(), resId);
    }

    public static Drawable getDrawable (@DrawableRes int resId) {
        return ContextCompat.getDrawable(DelegateApplication.getContext(), resId);
    }

    public static String getString (@StringRes int resId) {
        return DelegateApplication.getContext().getResources().getString(resId);
    }

    public static String[] getStringArray (@ArrayRes int id) {
        return DelegateApplication.getContext().getResources().getStringArray(id);
    }
}
